package bdd.sql.server.bean;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;

/**
 * Bean ServerAuth.
 * @author Guillaume Pocas & Jean-Fraçois Augé
 */
@Entity
@Table(name = "kraken_server_auth")
public class ServerAuth {
	
	@Id
	@GeneratedValue
	@Column(name = "auth_id")
	private int auth_id;
	
	@Column(name = "auth_name", nullable = false, updatable = false, unique = true)
	private String auth_name;
	
	@Column(name = "ip_adress", nullable = false, updatable = false, unique = true)
	private String auth_ip_adress;
	
	@Column(name = "cluster_name", nullable = false, updatable = false, unique = true)
	private String auth_cluster_name;
	
	@OneToOne(mappedBy = "auth")
	private Keystore keystore;

	@ManyToOne(cascade = {CascadeType.ALL})
    @JoinColumn(name = "id_conf")
	private Configuration auth_conf;
	
	/**
	 * Construc	teur vide.
	 */
	public ServerAuth(){	}
	
	/**
	 * Créer un nouveau WebServer.
	 * @param name
	 * @param ip
	 * @param cluster
	 */
	public ServerAuth(String name, String ip_adress, String cluster_name) {
		this.auth_name = name;
		this.auth_ip_adress = ip_adress;
		this.auth_cluster_name = cluster_name;
	}

	public int getAuth_id() { return auth_id; }
	public void setAuth_id(int auth_id) { this.auth_id = auth_id; }

	public String getAuth_name() { return auth_name; }
	public void setAuth_name(String auth_name) { this.auth_name = auth_name; }

	public String getAuth_ip_adress() { return auth_ip_adress;	}
	public void setAuth_ip(String auth_ip_adress) { this.auth_ip_adress = auth_ip_adress; }

	public String getAuth_cluster_name() { return auth_cluster_name; }
	public void setAuth_cluster_name(String auth_cluster_name) { this.auth_cluster_name = auth_cluster_name; }
	
	public Keystore getKeystore() {	return keystore;	}
	public void setKeystore(Keystore keystore) {	this.keystore = keystore;	}
	
	public Configuration getConf() { return auth_conf; }
	public void setConf(Configuration auth_conf) { this.auth_conf = auth_conf; }

	@Override
	public String toString() { return getAuth_name(); }

}
